import { Slave } from "message-lite";
import { atClient } from "kjl-miniapp-message-lite-adaptor/dist/cjs/environment-hack/client";

export const client = new Slave({
  createSender() {
    return (message: any) => {
      return window.parent!.postMessage(message, '*');
    };
  },
  listenMessage(fn) {
    window.addEventListener('message', fn, false);
  },
  unListenMessage(fn: (message: any) => void): void {
    window.removeEventListener('message', fn, false);
  },
  transformMessage(message: MessageEvent) {
    return message.data;
  },
})

atClient(client)